<extend name="Layout/ins_page" />
<block name="content">
	{:W('PageHeader/simple',array('name'=>字段管理,'search'=>'N'))}
	<div class="operate panel panel-default">
		<div class="panel-body">
			<div class="pull-left">
				<a class="btn btn-sm btn-primary" onclick="go_return_url()">返回</a>
			</div>
			<div class="pull-right">
				<a onclick="add()" class="btn btn-sm btn-primary">新增</a>
				<a onclick="save()" class="btn btn-sm btn-primary">保存</a>
				&nbsp;|&nbsp;
				<a onclick="del()" class="btn btn-sm btn-danger">删除</a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-4 sub_left_menu ">
			<div class="well">
				<?php echo $menu ?>
			</div>
		</div>
		<div class="col-sm-8 ">
			<form method='post' id="form_data" class="well form-horizontal">
				<input type="hidden" name="type_id" id="type_id" value="{$type_id}">
				<input type="hidden" name="id" id="id" >
				<input type="hidden" id="opmode" name="opmode" value="add">
				<input type="hidden" name="ajax" id="ajax" value="1">
				<div class="form-group">
					<label class="col-sm-4 control-label" for="name">名称*：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" id="name" name="name" check="require" msg="请输入名称">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label" for="control_type">控件类型*：</label>
					<div class="col-sm-8">
						<select name="control_type" id="control_type" check="require" msg="请选择控件类型">
							<option value="">请选择 <option value="text">单行文本 <option value="date">日期 <option value="select">列表 <option value="radio">单选 <option value="checkbox">多选 <option value="textarea">多行文本 <option value="editor">编辑器 <option value="simple">简易编辑器 <option value="help">帮助 <option value="hr">分隔符
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label" for="control_layout">控件布局：</label>
					<div class="col-sm-8">
						<select name="control_layout" id="control_layout" check="require" msg="请选择控件布局">
							<option value="">请选择 <option value="1">两列 <option value="2">整行 <option value="3">帮助 <option value="4">分隔符
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label" for="control_data">控件数据：</label>
					<div class="col-sm-8">
						<input  class="form-control" type="text" id="control_data" name="control_data" >
					</div>
				</div>
				<div class="form-group =">
					<label class="col-sm-4 control-label" for="sort">排序：</label>
					<div class="col-sm-8">
						<input class="form-control" type="text" id="sort" name="sort" >
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label" for="validate">验证：</label>
					<div class="col-sm-8">
						<select name="validate" id="validate">
							<option value="">请选择 <option value="require">必选 <option value="email">邮件 <option value="number">数字
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label" for="msg">错误提示：</label>
					<div class="col-sm-8">
						<input  class="form-control" type="text" id="msg" name="msg" >
					</div>
				</div>
			</form>
		</div>
	</div>
	<form method='post'  class="well form-horizontal clearfix">
		<volist name="field_list" id="vo">
			{:W('FlowField',$vo)}
		</volist>
	</form>
</block>
<block name="js">
	<script type="text/javascript">
		function add() {
			$("#opmode").val("add");
			$("#id").val("");
			sendForm("form_data", "", "__SELF__");
		};

		function del() {
			ui_confirm('真的要删除吗?', function() {
				$("#opmode").val("del");
				sendForm("form_data", "", "__SELF__");
			});
		};

		function save() {
			if ($("#opmode").val() == "") {
				ui_error("请选择要修改的数据");
				return false;
			} else {
				sendForm("form_data", "", "__SELF__");
			}
		};

		function showdata(result) {
			for (var s in result.data) {
				set_val(s, result.data[s]);
			}
			$("#opmode").val("edit");
		}

		$(document).ready(function() {
			$(".sub_left_menu .tree_menu  a").click(function() {
				$(".sub_left_menu .tree_menu  a").removeClass("active");
				$(this).addClass("active");
				sendAjax("{:U('FlowType/get_field')}", "id=" + $(this).attr("node"), function(data) {
					showdata(data);
				});
				return false;
			});
		});

	</script>
</block>